<template>
    <div>
        <a-modal
         v-model:visible="visible" 
         :title="formState.id?(formState.view?'查看生产工艺':'编辑生产工艺'):'新增生产工艺'" 
         @ok="handleOk" 
         @cancel="visible = false"
         class="enterpriseDetails-addEdit2-edit-modal"
         width="100%"
         :footer="null"
         :forceRender="true"
        >
            <div v-if="visible">
                <div style="display: flex;border: 1px solid #d9d9d9;">
                    <div class="enterprise-info-left">
                        <div
                        class="info-left-item" v-for="(item,index) in enterpriseInfoLeftList" :key="index" 
                        :class="currentEnterInfoData.title == item.title?'select-enterInfoItem-box':''"
                        @click="selectEnterpriseInfoLeftClick(item)"
                        >
                            <span class="info-left-icon" :class="'iconfont '+item.icon" ></span>
                            <span class="info-left-text" >{{ item.title }}</span>
                        </div>
                    </div>
                    <div class="enterprise-info-right" style="flex: 1;" >
                        <div v-if="currentEnterInfoData.title == '药品注册信息'">
                            <a-form :form="form" layout="horizontal" class="form-descriptions-content-box"> 
                                <a-descriptions :column="3" bordered style="width: 100%;">
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            批准文号
                                        </span>
                                        <a-form-item class="zm-form-model">
                                            <a-input v-model:value="formState.fpzwh" placeholder="请输入批准文号"/>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText">*</span>
                                            通用名称
                                        </span>
                                        <a-form-item class="zm-form-model">
                                            <a-input
                                                v-model:value="formState.ftymc"
                                                placeholder="请输入通用名称"
                                                v-decorator="[
                                                    'ftymc', { initialValue:formState.ftymc, rules: rules.ftymc}
                                                ]"
                                            />
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            商品名
                                        </span>
                                        <a-form-item class="zm-form-model">
                                            <a-input v-model:value="formState.fspm" placeholder="请输入商品名"/>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            执行标准
                                        </span>
                                        <a-form-item class="zm-form-model">
                                            <a-input v-model:value="formState.fzxbz" placeholder="请输入执行标准"/>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            药品有效期
                                        </span>
                                        <a-form-item class="zm-form-model">
                                            <a-date-picker v-model:value="formState.fypyxq" placeholder="请选择药品有效期"/>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            药品分类
                                        </span>
                                        <a-form-item class="zm-form-model">
                                            <a-input v-model:value="formState.fcplb" placeholder="请输入药品分类"/>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            规格
                                        </span>
                                        <a-form-item class="zm-form-model">
                                            <a-textarea 
                                                placeholder="请输入规格"
                                                v-model:value="formState.fgg"
                                                :autosize="{ minRows: 1, maxRows: 10000 }"
                                            ></a-textarea>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    
                                    
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            批准文号有效期
                                        </span>
                                        <a-form-item class="zm-form-model">
                                            <a-date-picker v-model:value="formState.fpzwhyxq" placeholder="请选择批准文号有限期"/>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3">
                                        <span slot="label" class="descriptions-label-slot">
                                            剂型
                                        </span>
                                        <a-form-item class="zm-form-model">
                                            <a-input v-model:value="formState.fjx" placeholder="请输入剂型"/>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3">
                                        <span slot="label" class="descriptions-label-slot">
                                            操作
                                        </span>
                                        <a-form-item class="zm-form-model">
                                            <div style="
                                                display: flex; justify-content: flex-start;
                                                width: 100%;
                                                background-color: #fff;">
                                                <a-button @click="visible = false">取消</a-button>
                                                <a-button v-if="!formState.view" style="margin: 0 20px;" class="blue-btn" type="primary" @click="handleOk(true)">保存</a-button>
                                                <!-- <a-button v-if="!formState.view" class="blue-btn" type="primary" @click="handleOk(false)">保存并关闭</a-button> -->
                                            </div>
                                        </a-form-item>
                                       
                                    </a-descriptions-item>
                                </a-descriptions>
                            </a-form>
                            
                        </div>
                        <div v-if="currentEnterInfoData.title == '药品生产状况'">
                            <div v-if="!formState.id">（注：请先保存药品注册信息）</div>
                            <div v-else>
                                <commpVxeTable
                                    :key="refreshTable"
                                    ref="productionRecordsVxeTable"
                                    :config="{
                                        api:assessCheckApi.spcyQyInfoqueryScjlPageList,
                                        rowId: 'id',
                                        height:windowInnerHeight - 250,
                                        paramet:{
                                            fpzid:formState.id,
                                        }
                                    }" 
                                    :isCanWrap="true"
                                    :columns="productionRecordsColumnsVxe" 
                                    :formItem="[{
                                        label: '产品名称',
                                        model: 'fspm',
                                    }]"
                                    
                                >  
                                    <template v-slot:externalOperations="{data}" v-if="!formState.isDisabled">
                                        <vxe-form-item>
                                            <template>
                                                <a-button class="blue-btn" type="primary" @click="addClick(0)">新增</a-button>
                                            </template>
                                        </vxe-form-item>
                                    </template>
                                    <template v-slot:operation_btn="{row}" data-desc="自定操作栏">
                                        <a-form layout="inline" class="search-form" >
                                            <a-form-item v-if="!formState.isDisabled">
                                                <a-button class="blue-btn" type="primary" @click="editClick(row,0)" >编辑</a-button>
                                            </a-form-item>
                                            <a-form-item v-if="formState.isDisabled">
                                                <a-button class="blue-btn" type="primary" @click="editClick(row,0,true)" >查看</a-button>
                                            </a-form-item>
                                            <a-form-item v-if="!formState.isDisabled">
                                                <a-button class="red-btn" type="primary" @click="deleteClick(row,0)" >删除</a-button>
                                            </a-form-item>
                                        </a-form> 
                                    </template>
                                </commpVxeTable>
                                
                            </div>
                            <addEdit0 ref="addEditRef0" @editItem="editItem" @addItem="addItem" />
                        </div>
                        <div v-if="currentEnterInfoData.title == '关键指标'">
                            <div v-if="!formState.id">（注：请先保存药品注册信息）</div>
                            <div v-else>
                                <commpVxeTable
                                    :key="refreshTable"
                                    ref="headmanVxeTable"
                                    :config="{
                                        api:assessCheckApi.spcyQyInfoqueryQyGjzbPageList,
                                        rowId: 'id',
                                        height:windowInnerHeight - 250,
                                        paramet:{
                                            fpzid:formState.id,
                                        }
                                    }" 
                                    :isCanWrap="true"
                                    :columns="keyIndicatorsColumnsVxe" 
                                    :formItem="[{
                                        label: '项目名称',
                                        model: 'fxmmc',
                                    }]"
                                    :conditionBtnRow="true"
                                    
                                >  
                                    <template v-slot:externalOperations="{data}" v-if="!formState.isDisabled">
                                        <vxe-form-item>
                                            <template>
                                                <a-button class="blue-btn" type="primary" @click="addClick(1)">新增</a-button>
                                            </template>
                                        </vxe-form-item>
                                    </template>
                                    <template v-slot:operation_btn="{row}" data-desc="自定操作栏">
                                        <a-form layout="inline" class="search-form" >
                                            <a-form-item v-if="!formState.isDisabled">
                                                <a-button class="blue-btn" type="primary" @click="editClick(row,1)" >编辑</a-button>
                                            </a-form-item>
                                            <a-form-item v-if="!formState.isDisabled">
                                                <a-button class="red-btn" type="primary" @click="deleteClick(row,1)" >删除</a-button>
                                            </a-form-item>
                                        </a-form> 
                                    </template>
                                </commpVxeTable>
                            </div>
                            <addEdit1 ref="addEditRef1" @editItem="editItem" @addItem="addItem" />
                        </div>
                        <div v-if="currentEnterInfoData.title == '生产工艺'">
                            <div class="process-handling-card">
                                <a-tabs type="card" v-model:activeKey="activeKey" @change="activeChange">
                                    <a-tab-pane key="生产工艺" tab="生产工艺"></a-tab-pane>
                                    <a-tab-pane key="车间和生产线情况" tab="车间和生产线情况"></a-tab-pane>
                                    <a-tab-pane key="附件" tab="附件"></a-tab-pane>
                                </a-tabs>
                            </div>
                            <div v-if="activeKey == '生产工艺'" style="border: 1px solid #38f;border-top: none;" >
                                <div v-if="!formState.id">（注：请先保存药品注册信息）</div>
                                <div v-else>
                                    <commpVxeTable
                                        :key="refreshTable"
                                        ref="headmanVxeTable"
                                        :config="{
                                            api:assessCheckApi.spcyQyInfoqueryScgyByPz,
                                            rowId: 'id',
                                            height:windowInnerHeight - 280,
                                            paramet:{
                                                fpzid:formState.id,
                                            }
                                        }" 
                                        :isCanWrap="true"
                                        :columns="ProcessColumnsVxe" 
                                        :formItem="[{
                                            label: '工序名称',
                                            model: 'fgxmc',
                                        }]"
                                        :conditionBtnRow="true"
                                        
                                    >  
                                        <template v-slot:externalOperations="{data}" v-if="!formState.isDisabled">
                                            <vxe-form-item>
                                                <template>
                                                    <a-button class="blue-btn" type="primary" @click="addClick(2)">新增</a-button>
                                                </template>
                                            </vxe-form-item>
                                        </template>
                                        <template v-slot:operation_btn="{row}" data-desc="自定操作栏">
                                            <a-form layout="inline" class="search-form" >
                                                <a-form-item v-if="!formState.isDisabled">
                                                    <a-button class="blue-btn" type="primary" @click="editClick(row,2)" >编辑</a-button>
                                                </a-form-item>
                                                <a-form-item v-if="!formState.isDisabled">
                                                    <a-button class="red-btn" type="primary" @click="deleteClick(row,2)" >删除</a-button>
                                                </a-form-item>
                                            </a-form> 
                                        </template>
                                    </commpVxeTable>
                                </div>
                                <addEdit2 ref="addEditRef2" @editItem="editItem" @addItem="addItem" />
                            </div>
                            <div v-if="activeKey == '车间和生产线情况'" style="border: 1px solid #38f;border-top: none;">
                                <div v-if="!formState.id">（注：请先保存药品注册信息）</div>
                                <div v-else>
                                    <commpVxeTable
                                        :key="refreshTable"
                                        ref="headmanVxeTable"
                                        :config="{
                                            api:assessCheckApi.spcyQyInfoquerySccjByPz,
                                            rowId: 'id',
                                            height:windowInnerHeight - 280,
                                            paramet:{
                                                fpzid:formState.id,
                                            }
                                        }" 
                                        :isCanWrap="true"
                                        :columns="workshopLineColumnsVxe" 
                                        :formItem="[{
                                            label: '车间名称',
                                            model: 'fcjmc',
                                        }]"
                                        :conditionBtnRow="true"
                                        
                                    >  
                                        <template v-slot:externalOperations="{data}" v-if="!formState.isDisabled">
                                            <vxe-form-item>
                                                <template>
                                                    <a-button class="blue-btn" type="primary" @click="addClick(3)">新增</a-button>
                                                </template>
                                            </vxe-form-item>
                                        </template>
                                        <template v-slot:operation_btn="{row}" data-desc="自定操作栏">
                                            <a-form layout="inline" class="search-form" >
                                                <a-form-item v-if="!formState.isDisabled">
                                                    <a-button class="blue-btn" type="primary" @click="editClick(row,3)" >编辑</a-button>
                                                </a-form-item>
                                                <a-form-item v-if="!formState.isDisabled">
                                                    <a-button class="red-btn" type="primary" @click="deleteClick(row,3)" >删除</a-button>
                                                </a-form-item>
                                            </a-form> 
                                        </template>
                                    </commpVxeTable>
                                </div>
                                <addEdit3 ref="addEditRef3" @editItem="editItem" @addItem="addItem" />
                            </div>
                            <div v-if="activeKey == '附件'" style="border: 1px solid #38f;border-top: none;">
                                <div v-if="!formState.id">（注：请先保存药品注册信息）</div>
                                <div v-else>
                                    <commpVxeTable
                                        :key="refreshTable"
                                        ref="fileVxeTableRef"
                                        :config="{
                                            api:assessCheckApi.spcyQyInfoqueryScgyWj,
                                            rowId: 'id',
                                            height:windowInnerHeight - 230,
                                            autoHidden:true,
                                            paramet:{
                                                fpzid:formState.id,
                                            }
                                        }" 
                                        :isCanWrap="true"
                                        :columns="fileColumnsVxe" 
                                        :formItem="[{
                                            label: '附件名称',
                                            model: 'fwjxsmc',
                                        }]"
                                        :conditionBtnRow="true"
                                        
                                    >  

                                        <template v-slot:externalOperations="{data}" v-if="!formState.isDisabled">
                                            <vxe-form-item>
                                                <template>
                                                    <a-button class="blue-btn" type="primary" @click="addClick(4)">新增</a-button>
                                                </template>
                                            </vxe-form-item>
                                        </template>
                                        <template v-slot:fwjxsmc_file="{row}" >
                                            <div>
                                                <a >{{ row.fwjxsmc+row.fwjlx }}</a>
                                                <a-icon style="font-size: 16px;margin-left: 5px;color: #1ab394;" type="download" @click="downloadClick(row)"/>
                                            </div>
                                        </template>
                                        <template v-slot:operation_btn="{row}" data-desc="自定操作栏">
                                            <a-form layout="inline" class="search-form" >
                                                <a-form-item v-if="!formState.isDisabled">
                                                    <a-button class="blue-btn" type="primary" @click="editClick(row,4)" >编辑</a-button>
                                                </a-form-item>
                                                <a-form-item v-if="!formState.isDisabled">
                                                    <a-button class="red-btn" type="primary" @click="deleteClick(row,4)" >删除</a-button>
                                                </a-form-item>
                                            </a-form> 
                                        </template>
                                    </commpVxeTable>
                                    <addEdit4 ref="addEditRef4" @editItem="editItem" @addItem="addItem" @fileSuccessChange="fileSuccessChange('fileVxeTableRef')" @downloadClick="downloadClick" />
                                </div>
                            </div>
                            <!-- <vxe-table
                            border
                            resizable
                            show-overflow
                            ref="xTable"
                            :loading="loading"
                            :data="tableData"
                            :edit-config="{trigger: 'manual', mode: 'row'}">
                                <vxe-column title="序号" type="seq" width="60"></vxe-column>
                                <vxe-column v-for="(item,index) in GyTh" :field="item.field" :title="item.title" :key="index" :edit-render="{}">
                                    <template #edit="{ row }">
                                        <vxe-input v-model="row.name" type="text"></vxe-input>
                                    </template>
                                </vxe-column>
                                <vxe-column title="操作" width="160">
                                    <template #default="{ row }">
                                    <template v-if="$refs.xTable.isActiveByRow(row)">
                                        <vxe-button @click="saveRowEvent(row)">保存</vxe-button>
                                        <vxe-button @click="cancelRowEvent(row)">取消</vxe-button>
                                    </template>
                                    <template v-else>
                                        <vxe-button @click="editRowEvent(row)">编辑</vxe-button>
                                    </template>
                                    </template>
                                </vxe-column>
                            </vxe-table> -->
                        </div>
                    </div>
                </div>
            </div>
            
        </a-modal>
    </div>
</template>
<script>
import compSelector from '@/components/compSelector/compSelector.vue'
import moment from 'moment'
import assessCheckApi from './service/api'
import commpVxeTable from '@/components/commp-vxe-table/commp-vxe-table.vue'
import addEdit0 from './productionRecords/addEdit.vue'
import addEdit1 from './keyIndicators/addEdit0.vue'
import addEdit2 from './keyIndicators/addEdit2.vue'
import addEdit3 from './keyIndicators/addEdit3.vue'
import addEdit4 from './keyIndicators/addEdit4.vue'
import blobType from '@/common/blobType'
import {
    spcyQyInfoupdateScjl,
    spcyQyInfodeleteScjl,
    spcyQyInfoaddScjl,
    spcyQyInfoupdateGjzb,
    spcyQyInfodeleteGjzb,
    spcyQyInfoaddGjzb,
    spcyQyInfoupdateScgy,
    spcyQyInfodeleteScgy,
    spcyQyInfoaddScgyByPz,
    spcyQyInfoaddSccjByPz,
    spcyQyInfoupdateSccj,
    spcyQyInfodeleteSccj,
    spcyQyInfoqueryScgyWj,
    getCrossLocalFile,
} from './service/index'
export default {
    components:{
        compSelector,
        commpVxeTable,
        addEdit0,
        addEdit1,
        addEdit2,
        addEdit3,
        addEdit4,
    },
    props:{

    },
    data(){
        return{
            assessCheckApi,
            visible:false,
            formState:{},
            refreshTable:null,
            windowInnerHeight:window.innerHeight,
            form: this.$form.createForm(this, { name: 'coordinated' }),
            rules:{
                ftymc: [{
                    required: true,
                    message: '请输入偏差主题',
                    trigger: 'blur',
                }],
            },
            enterpriseInfoLeftList:[{
                title:'药品注册信息',
                icon:'spcy-icon-jichuxinxi',
            },{
                title:'生产工艺',
                icon:'spcy-icon-zhengqimenhu_zhengjianxinxi',
            },{
                title:'药品生产状况',
                icon:'spcy-icon-renyuanxinxi',
            },{
                title:'关键指标',
                icon:'spcy-icon-tubiaozhizuomoban-',
            }],
            currentEnterInfoData:{
                title:'药品注册信息',
                icon:'spcy-icon-jichuxinxi',
            },
            productionRecordsColumnsVxe:[{ 
                type: 'checkbox', 
                width: 60 ,
                fixed: 'left'
            },{
                title: '产品批号',
                field: 'fcpph',
            },{
                title: '批量',
                field: 'fpl',
            },{
                title: '批准文号',
                field: 'fpzwh',
            },{
                title: '产品名称',
                field: 'fspm',
            },{
                title: '药品分类',
                field: 'fcplb',
            },{
                title: '生产日期',
                field: 'fscrq',
            },{
                title: '产品规格',
                field: 'fgg',
            },{
                title: '包装规格',
                field: 'fbzgg',
            },{
                title: '操作',
                field: 'id',
                slots: {
                    // 使用插槽模板渲染
                    default: 'operation_btn',
                },
                width:180,
            }],
            keyIndicatorsColumnsVxe:[{ 
                type: 'checkbox', 
                width: 60 ,
                fixed: 'left'
            },{
                title: '项目名称',
                field: 'fxmmc',
            },{
                title: '警戒限',
                field: 'fjjx',
            },{
                title: '行动限',
                field: 'fhdx',
            },{
                title: '合格限',
                field: 'fhgx',
            },{
                title: '操作',
                field: 'id',
                slots: {
                    // 使用插槽模板渲染
                    default: 'operation_btn',
                },
                width:180,
            }],
            ProcessColumnsVxe:[{ 
                type: 'checkbox', 
                width: 60 ,
                fixed: 'left'
            },{
                title: '工序名称',
                field: 'fgxmc',
            },{
                title: '关键工艺及参数',
                field: 'fgjgyjcs',
            },{
                title: '关键设备',
                field: 'fgjsb',
            },{
                title: '投料',
                field: 'ftl',
            },{
                title: '质量控制参数',
                field: 'fzlkzcs',
            },{
                title: '备注',
                field: 'fbz',
            }],
            workshopLineColumnsVxe:[{
                title: '车间编号',
                field: 'fcjbh',
            },{
                title: '车间名称',
                field: 'fcjmc',
            },{
                title: '生产线',
                field: 'fscx',
            },{
                title: '生产地址',
                field: 'fscdz',
            },{
                title: '负责人',
                field: 'ffzr',
            },{
                title: '区域分类',
                field: 'fqyfl',
            },{
                title: '预警值',
                field: 'fyjz',
            },{
                title: '超标值',
                field: 'fcbz',
            },{
                title: '投用时间',
                field: 'ftysj',
            },{
                title: '有效状态',
                field: 'fyxzt',
            },],
            fileColumnsVxe:[{
                title: '附件名称',
                field: 'fwjxsmc',
            },{
                title: '附件说明',
                field: 'fwjlx5',
            },{
                title: '附件备注',
                field: 'fwjlx6',
            },{
                title: '附件',
                field: 'id',
                slots: {
                    // 使用插槽模板渲染
                    default: 'fwjxsmc_file',
                },
            },{
                title: '操作',
                field: 'id',
                slots: {
                    // 使用插槽模板渲染
                    default: 'operation_btn',
                },
                width:180,
            }],
            methodList:[{
                name:'物料目录',
                editName:spcyQyInfoupdateScjl,
                deleteName:spcyQyInfodeleteScjl,
                addName:spcyQyInfoaddScjl,
            },{
                name:'关键指标',
                editName:spcyQyInfoupdateGjzb,
                deleteName:spcyQyInfodeleteGjzb,
                addName:spcyQyInfoaddGjzb,
            },{
                name:'生产工艺',
                editName:spcyQyInfoupdateSccj,
                deleteName:spcyQyInfodeleteSccj,
                addName:spcyQyInfoaddSccjByPz,
            },{
                name:'生产车间',
                editName:spcyQyInfoupdateScgy,
                deleteName:spcyQyInfodeleteScgy,
                addName:spcyQyInfoaddScgyByPz,
            }],
            GyTableData:[],
            GyTh:[{
                title:'工序名称',
                field:'fgxmc',
            },{
                title:'关键工艺及参数',
                field:'fgjgyjcs',
            },{
                title:'关键设备',
                field:'fgjsb',
            },{
                title:'投料',
                field:'ftl',
            },{
                title:'质量控制参数',
                field:'fzlkzcs',
            },{
                title:'备注',
                field:'fbz',
            }],
            activeKey:'生产工艺',
            GYfileList:[],
        }
    },
    watch:{

    },
    mounted(){
    },
    methods:{
        getData(val){
            this.refreshTable = Date.now()
            this.formState = {}
            this.formState = {...val,fpzwhyxq:val.fpzwhyxq?moment(val.fpzwhyxq,'YYYY-MM-DD'):'',fypyxq:val.fypyxq?moment(val.fypyxq,'YYYY-MM-DD'):''}
            this.currentEnterInfoData = {
                title:'药品注册信息',
                icon:'spcy-icon-jichuxinxi',
            }
            this.activeKey = '生产工艺'
        },
        selectEnterpriseInfoLeftClick(item){
            this.currentEnterInfoData = item
            this.refreshTable = Date.now()
        },
        activeChange(val){
            this.refreshTable = Date.now()
            if(val == '附件'){
                this.getGYfile()
            }
        },
        getGYfile(){
            spcyQyInfoqueryScgyWj({fpzid:this.formState.id}).then(res=>{
                if(res.code == 200){
                    //console.log('获取附件列表',res)
                }else{

                }
            })
        },
        downloadClick(val){
            
            var that = this
            var fileName = val.fwjxsmc
            let param = {id:val.id}
            getCrossLocalFile(param).then((data) => {
                if (!data) {
                    that.$message.warning('文件下载失败')
                    return
                }else{
                // if (typeof window.navigator.msSaveBlob !== 'undefined') {
                //     window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }))
                // } else {
                    let url = window.URL.createObjectURL(new Blob([data], { type: blobType.type[blobType.suffix.indexOf(val.fwjlx)] }))
                    let link = document.createElement('a')
                    link.style.display = 'none'
                    link.href = url
                    link.setAttribute('download', fileName + val.fwjlx)
                    document.body.appendChild(link)
                    link.click()
                    document.body.removeChild(link) //下载完成移除元素
                    window.URL.revokeObjectURL(url) //释放掉blob对象
                // }
                }
            })
        },
        fileSuccessChange(val){
            this.$refs[val].searchEvent()
        },
        addClick(index){
            let refName = 'addEditRef'+index
            this.$refs[refName].getData({fqyid:this.formState.fqyid,fpzid:this.formState.id,...this.formState,index:index},{index:index})
            this.$refs[refName].visible = true
        },
        editClick(val,index,view){
            //console.log(val)
            let refName = 'addEditRef'+index
            this.$refs[refName].getData({fqyid:this.formState.fqyid,fpzid:this.formState.id,...this.formState,view:view?true:false,isDisabled:view?true:false},{...val,index:index,view:view?true:false,isDisabled:view?true:false})
            this.$refs[refName].visible = true
        },
        addItem(val,vis,isTip){
            //console.log('新增',val)
            let refName = 'addEditRef'+val.index
            this.methodList[val.index].addName(val).then(res=>{
                if(res.code == 200){
                    this.refreshTable = Date.now()
                    if(!isTip){
                        this.$message.success(res.message)
                    }
                    
                    this.$refs[refName].getData({fqyid:this.formState.fqyid,fpzid:this.formState.id,...this.formState},{...val,id:res.result.id})
                    this.$refs[refName].visible = vis
                    //console.log(res)
                }else{
                    this.$message.warning(res.message)
                }
            })
        },
        editItem(val,vis){
            //console.log('编辑',val)
            let refName = 'addEditRef'+val.index
            this.methodList[val.index].editName(val).then(res=>{
                if(res.code == 200){
                    this.refreshTable = Date.now()
                    this.$message.success(res.message)
                    this.$refs[refName].visible = vis
                }else{
                    this.$message.warning(res.message)
                }
            })
        },
        deleteClick(val,index){
            var that = this
            this.$confirm({
                title:'您确认要删除吗？',
                // icon: createVNode(ExclamationCircleOutlined),
                onOk() {
                    that.methodList[index].deleteName({id:val.id}).then(res=>{
                        if(res.code == 200){
                            that.$message.success('删除成功')
                            that.refreshTable = Date.now()
                        }else{
                            that.$message.warning(res.message)
                        }
                    })
                },
                
            });
        },
        handleOk(val){
            this.form.validateFields((err, values) => {
                if (!err) {
                    if(this.formState.id){
                        this.$emit('editItem',{
                            ...this.formState,
                            ...values,
                            fpzwhyxq:this.formState.fpzwhyxq?moment(this.formState.fpzwhyxq).format('YYYY-MM-DD'):'',
                            fypyxq:this.formState.fypyxq?moment(this.formState.fypyxq).format('YYYY-MM-DD'):'',
                        },val)
                    }else{
                        this.$emit('addItem',{
                            ...this.formState,
                            ...values,
                            fpzwhyxq:this.formState.fpzwhyxq?moment(this.formState.fpzwhyxq).format('YYYY-MM-DD'):'',
                            fypyxq:this.formState.fypyxq?moment(this.formState.fypyxq).format('YYYY-MM-DD'):'',
                        },val)
                    }
                    
                }
            })
        },
    }
}
</script>
<style lang="less">
.enterpriseDetails-addEdit2-edit-modal{
    .ant-modal {
        max-width: 100%;
        top: 0;
        padding-bottom: 0;
        margin: 0;
    }
    .ant-modal-content {
        display: flex;
        flex-direction: column;
        height: 100vh;
    }
    .ant-modal-body {
        flex: 1;
        height: calc(100vh);
        overflow-y: auto;
    }
    .enterprise-info-left{
        height: calc(100vh - 116px);
        overflow-y: auto;
        // border: 1px solid #d9d9d9;
        border-right: 1px solid #d9d9d9;
        min-width: 180px;
        max-width: 20%;
        padding: 8px 0;
        
        .info-left-item{
            padding: 8px 10px;
            display: flex;
            align-items: center;
            cursor: pointer;
            .info-left-icon{
                margin-right: 5px;
                font-size: 18px;
                color: #999;
            }
            .info-left-text{
                font-size: 17px;
                font-weight: 600;
                color: #999;
            }
        }
        .select-enterInfoItem-box{
            background-color: #e6f7ff;
            border-right: 5px solid #38f;
            .info-left-icon,.info-left-text{
                color: #242424 !important;
            }
        }
    }
    .enterprise-info-right{
        height: calc(100vh - 116px);
        overflow-y: auto;
        padding: 8px;
    }

    .add-edit-form{
        display: flex;
        flex-wrap: wrap;
        .ant-form-item{
            display: flex;
            margin-bottom: 5px;
        }
        .ant-form-item-label{
            width: 110px;
        }
        .ant-form-item-control-wrapper{
            width: 100%;
        }
        .flex-1-box{
            width: 100%;
            .ant-form-item-control-wrapper{
                flex: 1;
            }
        }
    }
}
.enterpriseDetails-addEdit2-form-box{
        // padding: 0 15px;
        
        // margin-top: 20px;
        margin-bottom: 8px;
        p {
            margin-block: 0px !important;
        }
        .ant-descriptions-bordered .ant-descriptions-item-label{
            font-weight: 600;
            color: rgba(0, 0, 0, 0.85);
            background-color:#e6f7ff;
            width: 150px !important;
            text-align: center;
            font-size: 16px;
            font-family:simHei !important;
        }
        .ant-descriptions-bordered .ant-descriptions-item-label, .ant-descriptions-bordered .ant-descriptions-item-content{
            padding: 5px 10px !important;
            .ant-form-item {
                margin-bottom: 0 !important;
            }

        }
        .descriptions-row .descriptions-label-slot{
            display: flex;
            align-items: center;
            width: 120px !important;//确保左侧固定文字不会换行
            justify-content: center;
            text-align: center;
        }
        .xhText{
            color: #f5222d;
            line-height: 31px;
            font-size: 14px;
            font-weight: 600;
            height: 30px;
        }
        .descriptions-item-center{

        }
        .ant-form-inline .ant-form-item-with-help{
            margin-bottom: 0px !important;
        }
        .zm-form-model{
            display: flex;
            .ant-form-item-control-wrapper{
                flex: 1;
            }
        }
        .ant-descriptions-bordered .ant-descriptions-row{
            border-bottom: 1px solid #e4e3e3;
        }
        .ant-descriptions-bordered .ant-descriptions-item-label, .ant-descriptions-bordered .ant-descriptions-item-content{
            border-right: 1px solid #e4e3e3;
            min-width: 100px;
        }
        .ant-descriptions-bordered .ant-descriptions-view{
            border: 1px solid #e4e3e3;
            border-right: 0;
        }
        .ant-descriptions-row:last-child{
            border-bottom: 0;
        }

    }
</style>